//
//  MyInvite_Friends.m
//  XJMCustomer
//
//  Created by 洗脚么_one on 2017/11/28.
//  Copyright © 2017年 Mr.hu. All rights reserved.
//

#import "MyInvite_Friends.h"
#import "MyinviteFriendCell.h"
#import "MineAccountTBV.h"

@interface MyInvite_Friends ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *invite_tableview;
@property (weak, nonatomic) IBOutlet UILabel *Coupon_number;
@property (nonatomic,strong)  NSMutableArray * mutarr_invite;

@end

@implementation MyInvite_Friends

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationController setNavigationBarHidden:NO];
    [self addLeftBtn:[UIImage imageNamed:@"fanhui"] Action:@selector(backToPrevious)];
    self.title = @"我的邀请";
    [self addRightLabel:@"我的账户" Action:@selector(checkCouponMeth)];
    self.mutarr_invite = [NSMutableArray array];
    
    self.invite_tableview.delegate = self;
    self.invite_tableview.dataSource = self;
    self.invite_tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.invite_tableview registerNib:[UINib nibWithNibName:@"MyinviteFriendCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MyinviteFriendCell"];
    
    [XJHttpClass MyInviteFriendsListFinishblock:^(id response, NSString *errStr) {
        
        if (errStr) {
//            [XJToolClass tipAnimationWith:errStr];
        }else{
            
            NSDictionary * dictdata = response[@"data"];
            if ([dictdata isKindOfClass:[NSDictionary class]]) {
                if (dictdata[@"money_sum"]) {
                    self.Coupon_number.text = [NSString stringWithFormat:@"获得%@元",dictdata[@"money_sum"]];
                }else{
                    self.Coupon_number.text = [NSString stringWithFormat:@"获得0元"];
                }
                
                self.mutarr_invite =  dictdata[@"list"];
                [self.invite_tableview reloadData];
            }
        }
    }];
}

- (void)checkCouponMeth{
    
    MineAccountTBV * MineAccount= [[MineAccountTBV alloc]init];
    MineAccount.Input_price = [TechSimple registerpass].User_TechTotalMoney;
    MineAccount.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:MineAccount animated:YES];
}

#pragma mark - TableViewDatasource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.mutarr_invite.count;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MyinviteFriendCell * friend=[tableView dequeueReusableCellWithIdentifier:@"MyinviteFriendCell" forIndexPath:indexPath];
    friend.selectionStyle = UITableViewCellSelectionStyleNone;
    [friend setData:self.mutarr_invite[indexPath.row]];
    return friend;
    
}

#pragma mark TableViewDelegate
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}



@end
